#include <iostream>
#include <cmath>

using namespace std;

static bool number_2025(uint64_t num, uint64_t root) {
    uint64_t d = 1;
    for (uint64_t d = 10; d < num; d *= 10) {
        uint64_t a = num % d;
        uint64_t b = num / d;
        if (a + b == root && 10 * a >= d) // fuck leading zeros
            return true;
    }
    return false;
}

int main() {
    uint64_t ans = 0;
    for (uint64_t i = 2; i < sqrt(1e16); ++i) {
        uint64_t s = i * i;
        if (number_2025(s, i))
            ans += s;
    }
    cout << ans << endl;
}